package model.user;


import common.GenericSerializationUtil;

import java.io.*;
import java.util.ArrayList;
import java.util.List;

/*
  用户类
 */
public class User implements Serializable {
    private static List<User> users = new ArrayList<>();
    private String Name ;//姓名
    private String ContactInformation ;//联系方式
    private String IDNumber ;//身份证号
    private String Membership ;//会员等级
    private String Password ;//密码

    public User() {
    }
    public User(String name, String contactInformation, String IDNumber, String membership, String password) {
        Name = name;
        ContactInformation = contactInformation;
        this.IDNumber = IDNumber;
        Membership = membership;
        Password = password;
    }
    public User(String name, String password){
        Name = name;
        Password = password;
    }

    public static List<User> getUsers() {
        return users;
    }

    public static void setUsers(List<User> users) {
        User.users = users;
    }


    public void addUser(User user) {
        users.add(user);
    }
    public static User judge(String name,String password){
        //判断用户是否存在并返回这个User如果没有返回null
        for (User user : users) {
            if (user.getName().equals(name) && user.getPassword().equals(password)) {
                return user;
            }
        }
        return null;
    }

    @Override
    public String toString() {
        return "User{" +
                "Name='" + Name + '\'' +
                ", ContactInformation='" + ContactInformation + '\'' +
                ", IDNumber='" + IDNumber + '\'' +
                ", Membership='" + Membership + '\'' +
                ", Password='" + Password + '\'' +
                '}';
    }


    public String getPassword() {
        return Password;
    }

    public void setPassword(String password) {
        Password = password;
    }

    public String getName() {
        return Name;
    }

    public void setName(String name) {
        Name = name;
    }

    public String getContactInformation() {
        return ContactInformation;
    }

    public void setContactInformation(String contactInformation) {
        ContactInformation = contactInformation;
    }

    public String getIDNumber() {
        return IDNumber;
    }

    public void setIDNumber(String IDNumber) {
        this.IDNumber = IDNumber;
    }

    public String getMembership() {
        return Membership;
    }

    public void setMembership(String membership) {
        Membership = membership;
    }
}

